package com.lvwenguo.controller.stock;
/*
* 库存信息
* */

import com.lvwenguo.service.StockInter;
import com.lvwenguo.service.serviceImple.StockImple;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/StockServlet")
public class StockServlet extends HttpServlet {
    StockInter stockInter=new StockImple();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //表示是库存信息模糊查询
        if(Integer.parseInt(req.getParameter("id"))==0){
            String name = req.getParameter("name");
            req.setAttribute("stock",stockInter.selectMohu(0,name));
            req.getRequestDispatcher("/view/stock/stock_list.jsp").forward(req,resp);

        }
        //表示库存修改记录模糊查询
        else if(Integer.parseInt(req.getParameter("id"))==1){
            String name = req.getParameter("name");
            req.setAttribute("stock",stockInter.selectMohu(1,name));
            req.getRequestDispatcher("/view/stock/stock_list.jsp").forward(req,resp);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
